import operate from '@dfeidao/atom-nodejs/db/operate';

interface Message {
	group_name: string;
	productid: string;
	client_type: string;
	group_number: string;
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	const { exec, update } = operate(action_id, session_id, '12');
	update('pub_form_group', {
		productid: msg.productid,
		client_type: msg.client_type,
		group_number: msg.group_number
	}, {
			group_name: msg.group_name
		});
	update('pub_form', {
		productid: msg.productid,
		client_type: msg.client_type,
		group_number: msg.group_number
	}, {
			group_name: msg.group_name
		});
	const ret = await exec();
	if (ret.code === 1) {
		return 'success';
	} else {
		return 'fail';
	}
}
